import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_tech_shop/src/context_extension.dart';
import 'package:flutter_tech_shop/src/shared/Product.dart';
import 'package:flutter_tech_shop/widgets/app_button.dart';

import 'product_page.dart';

class ProductDetail extends StatelessWidget {
  final Product product;

  const ProductDetail({
    super.key,
    required this.product,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('商品详情'),
      ),
      body: SingleChildScrollView(
        child: Stack(
          children: [
            Container(
              padding: EdgeInsets.only(left: 15, right: 15, bottom: 60),
              child: Column(
                children: [
                  Image.asset(
                    product.image,
                    width: double.maxFinite,
                    fit: BoxFit.fitWidth,
                  ),
                  Text(product.description)
                ],
              ),
            ),
            Positioned(
                left: 15,
                right: 15,
                bottom: 10,
                child: AppButton(
                    height: 40,
                    width: 200,
                    content: '立即购买',
                    onPressed: () {
                      context.push(
                        ProductPage(
                          productData: product,
                        ),
                      );
                    }))
          ],
        ),
      ),
    );
  }
}
